<?php

define('INSTALLDIR', dirname(__FILE__));
define('mySite', true);

require_once(INSTALLDIR.'/include/start.php');

define('APPLICATIONROOT', PROTOCOL.SERVER.preg_replace('/index.php$/i', '', $_SERVER['PHP_SELF']));

if(Util::config('site', 'maintenance')) {
    $page = 'maintenance';
    $page_file = INSTALLDIR."/include/$page.php";
}
else {
    $page = $_GET['page'] ? $_GET['page'] : 'inicial';
    $page_file = INSTALLDIR."/pages/$page.php";
}

if(file_exists($page_file)){
    require_once($page_file);
    $page_class = ucfirst($page).'Page';
    $page_object = new $page_class();

    if(call_user_func(array($page_object, 'prepare'), $_REQUEST)){
        call_user_func(array($page_object, 'handle'), $_REQUEST);
    }
}

?>
